<?php
class M_Area extends Apps_Db_Table_Abstract {
    protected $_name = 'area';

    //show home with hotel
    public function listareaByCountryId($countryId) {
        $q = $this->_db
                  ->select()
                  ->from('area', null)
                  ->join('country', 'country.id = area.country_id', null)
                  ->where('country.id =? ', $countryId)
                  ->group('area.id')
                  ->order('area.sorting_number')
                  ->columns(array('id' => 'area.id'));

        if($this->getLang() == 'en') {
            $q->columns(array('name' => 'area.en_name'));
        } else $q->columns(array('name' => 'area.name'));

        return $q;
    }

    public function getareaById($id) {
        $q = $this->_db
                  ->select()
                  ->from($this->_name, null)
                  ->where('area.id =? ', $id)
                  ->order('area.sorting_number')
                  ->columns(array('id'         => 'area.id',
                                  'country_id' => 'area.country_id'));

        if($this->getLang() == 'en') {
            $q->columns(array('name' => 'area.en_name'));
        } else $q->columns(array('name' => 'area.name'));

        return $q;
    }
}